/*!
 *
 * \file    Mxd0250API.h
 *
 * \brief    SDK Interface header file.
 *
 * Header file of the functions declaration about MIRA CMMB Demod SDK
 *
 * \par    Include files
 * - Mxd0250API.h
 *
 * \par    Copyright (c) 2008 Maxscend Technologies Inc. All rights reserved
 *
 * PROPRIETARY RIGHTS of Maxscend Technologies Inc. are involved in
 * the subject matter of this material.  All manufacturing, reproduction,
 * use, and sales rights pertaining to this subject matter are governed
 * by the license agreement.  The recipient of this software implicitly
 * accepts the terms of the license.
 *
 * \version
 * Revision of last commit: $Rev: 997 $
 * Author of last commit  : $Author: maxscend\chaohui.jiang $
 * Date of last commit    : $Date: 2010-12-29 23:02:12 +0800 (星期三, 29 十二月 2010) $
 *
 */
 
#ifndef __MXD_SDK_API_H__
#define __MXD_SDK_API_H__

#ifdef __cplusplus 
extern "C" {
#endif

#include "Mxd0250OAL.h"
#include "Mxd0250Config.h"

#define MIRA_SDK_VERSION "V1.9 $Rev: 997 $"
     
/************************* Structure Definition ****************************/
typedef enum{
	MXD_RTN_OK = 0,
	MXD_GENERAL_ERROR = -1000,
	MXD_TIMEOUT_ERROR,
	MXD_PARAMETER_ERROR,
	MXD_DEMUXER_CONTINUE,
	MXD_DEMUXER_STOP,
	MXD_DEMUXER_NOTFOUND,
	MXD_DESCRAMBLE_OK,
	MXD_DEMUXER_DATA_REPEAT,
	MXD_CTS_FAIL,
    MXD_FTS_FAIL_INT,
    MXD_FTS_FAIL_CURRENT,
    MXD_TIME_OUT,
    MXD_BIG_DELAY,
    MXD_NORMAL_DELAY,
    MXD_ACS_MODE,
    MXD_SNR_MODE,
	MXD_POOR_SIGNAL,
	MXD_SFO_UNLOCK,
	MXD_CLCHCRC_FAIL,
	MXD_SYSTEM_UNLOCK,
	MXD_SERVICESEARCH_STOP,
	MXD_POLLING_STATUS,
	MXD_CLCHCRC_PASS,
	MXD_CLCHDATA_OK,
}MXD_RETURN_CODE;

typedef enum{
	MXD_PM_SUSPEND = 0,
	MXD_PM_RESUME = 1,
}MXD_PM_MODE;

typedef struct{
	MXD_BOOL bLock;			   // lock==TRUE means the frequency has been locked.
	MXD_UINT32 nCurrentFrequency; // current Tuner working frequency
	MXD_INT32 nSignalStrength;		// signal strength in dbm
	MXD_UINT8  nSignalNoiseRatio;   // signal noise ratio
	MXD_UINT16 nLdpcErrPercent;		// LDPC error percentage 0 ~ 100
	MXD_UINT16 nLdpcWindow; 
	MXD_UINT16 nRSErrCount;
	MXD_UINT8  nStartedServiceCount;
	MXD_UINT32 nStartedServiceID[40];
	MXD_BOOL bRecoveryStatus;
}MXD_SYS_STATUS;

//////////////////////////////////////////////
typedef enum
{
    MXD_LANGUAGE_TYPE_CHINESE =0,
    MXD_LANGUAGE_TYPE_ENGLISH =1,
    MXD_LANGUAGE_TYPE_MAX = 10
}MXD_LANGUAGE_TYPE;

typedef struct
{
    MXD_UINT16      FreqPointId;
    MXD_UINT16      BandWidth;
    MXD_UINT32      CentralFreq;
}MXD_SYS_FREQPOINT;

typedef struct
{
    MXD_UINT16          MJD_Date;
    MXD_UINT8           Hour;
    MXD_UINT8           Minute;
    MXD_UINT8           Second;
}MXD_DATE_TIME;

/////////*Video Frame Structs*/////////////////////////////////////
typedef enum
{
    MXD_VIDEO_CODEC_TYPE_AVS =0,
    MXD_VIDEO_CODEC_TYPE_H264 =1,
    MXD_VIDEO_CODEC_TYPE_OTHER =2    
}MXD_VIDEO_CODEC_TYPE;

typedef enum
{
    MXD_VIDEO_FRAME_RATE_25HZ =0,
    MXD_VIDEO_FRAME_RATE_30HZ =1,
    MXD_VIDEO_FRAME_RATE_12HZ =2,  //12.5hz
    MXD_VIDEO_FRAME_RATE_15HZ =3
}MXD_VIDEO_FRAME_RATE;

typedef struct _MXD_VIDEO_PARAM
{
    MXD_VIDEO_CODEC_TYPE  eCodecType;
    MXD_UINT32          nBitRate;
    MXD_UINT8         xStart;
    MXD_UINT8         yStart;
    MXD_UINT8         nPriority;
    MXD_UINT16          nHrWidth;
    MXD_UINT16          nVrWidth;
    MXD_VIDEO_FRAME_RATE  eFrameFreq;
    struct _MXD_VIDEO_PARAM *next;
}MXD_VIDEO_PARAM;

typedef enum
{
    MXD_VIDEO_FRAME_TYPE_I =0,
    MXD_VIDEO_FRAME_TYPE_P =1,
    MXD_VIDEO_FRAME_TYPE_B =2
}MXD_VIDEO_FRAME_TYPE; 

typedef struct
{
    MXD_UINT8         nStreamId;
    MXD_VIDEO_FRAME_TYPE  eType;
    MXD_UINT32          nStartPlayTime; //not Relative time!
    MXD_UINT8         *Data;
    MXD_UINT32          Size;
}MXD_STREAM_VIDEO_FRAME;

/////////*Audio frame structs*//////////////////////////////////////
typedef enum
{
    MXD_AUDIO_CODEC_TYPE_DRA =0,
    MXD_AUDIO_CODEC_TYPE_HEAAC =1,
    MXD_AUDIO_CODEC_TYPE_AAC =2
}MXD_AUDIO_CODEC_TYPE;

typedef enum
{
    MXD_AUDIO_SAMPLERATE_8KHZ =0,
    MXD_AUDIO_SAMPLERATE_12KHZ =1,
    MXD_AUDIO_SAMPLERATE_16KHZ =2,
    MXD_AUDIO_SAMPLERATE_22KHZ =3,  //22.05Khz
    MXD_AUDIO_SAMPLERATE_24KHZ =4,
    MXD_AUDIO_SAMPLERATE_32KHZ =5,
    MXD_AUDIO_SAMPLERATE_44KHZ =6,  //44.1Khz
    MXD_AUDIO_SAMPLERATE_48KHZ =7,
    MXD_AUDIO_SAMPLERATE_96KHZ =8,
    MXD_AUDIO_SAMPLERATE_MAX
}MXD_AUDIO_SAMPLERATE;

typedef struct _MXD_AUDIO_PARAM
{
    MXD_AUDIO_CODEC_TYPE  eCodecType;
    MXD_UINT32            nBitRate; 
    MXD_AUDIO_SAMPLERATE  eSampleRate;
    MXD_LANGUAGE_TYPE     eLanguage;
	struct _MXD_AUDIO_PARAM*  next;
}MXD_AUDIO_PARAM;

typedef struct
{
    MXD_UINT8         nStreamId;
    MXD_UINT32        nStartPlayTime; //not Relative time!
    MXD_UINT8         *Data;
    MXD_UINT32        Size;
}MXD_STREAM_AUDIO_FRAME;

typedef struct
{
	MXD_UINT8	*pContent;
	MXD_UINT16	nContentLen;
}MXD_MEDIA_UINT_STRUCT;

typedef struct
{
    MXD_MEDIA_UINT_STRUCT         *pVideoUnitList;
	MXD_UINT16										nVideoUnitCount;
    MXD_MEDIA_UINT_STRUCT         *pAudioUnitList;
	MXD_UINT16										nAudioUnitCount;
	void							*pReserved;
}MXD_MEDIA_UNIT_IN_FRAME;

//////////*Emergency Message Structs*/////////////////////////////////////
typedef enum
{
    MXD_EMERGENCY_EVENT_TYPE_TEST0 = 0,
    MXD_EMERGENCY_EVENT_TYPE_FLOOD_DROUGHT_DISASTER = 1,
    MXD_EMERGENCY_EVENT_TYPE_METEOROLOGIC_DISASTER,
    MXD_EMERGENCY_EVENT_TYPE_EARTHQUAKE_DISASTER,
    MXD_EMERGENCY_EVENT_TYPE_GEOLOGIC_DISASTER,
    MXD_EMERGENCY_EVENT_TYPE_SEA_DISASTER,
    MXD_EMERGENCY_EVENT_TYPE_BIOLOGY_DISASTER,
    MXD_EMERGENCY_EVENT_TYPE_FOREST_GRASSLAND_FIRE_DISASTER,
    MXD_EMERGENCY_EVENT_TYPE_TEST1 = 32,
    MXD_EMERGENCY_EVENT_TYPE_ENTERPRISE_SAFETY_ACCIDENT,
    MXD_EMERGENCY_EVENT_TYPE_TRAFFIC_ACCIDENT,
    MXD_EMERGENCY_EVENT_TYPE_PUBLIC_FACILITIES_ACCIDENT,
    MXD_EMERGENCY_EVENT_TYPE_ENVIRONMENTAL_POLLUTION,   // Environmental Pollution and Ecological Destruction 
    MXD_EMERGENCY_EVENT_TYPE_TEST2 = 64,
    MXD_EMERGENCY_EVENT_TYPE_INFECTIOUS_DISEASE_EPIDEMIC_SITUATION,
    MXD_EMERGENCY_EVENT_TYPE_GROUPMENT_UNKNOWN_DISEASE,
    MXD_EMERGENCY_EVENT_TYPE_FOOD_SAFETY_AND_OCCUPATIONAL_RISK,
    MXD_EMERGENCY_EVENT_TYPE_ANIMAL_DISEASE_EPIDEMIC_SITUATION,
    MXD_EMERGENCY_EVENT_TYPE_TEST3 = 96,
    MXD_EMERGENCY_EVENT_TYPE_TERRORIST_ATTACK_EVENT,
    MXD_EMERGENCY_EVENT_TYPE_ECONOMIC_SECURITY_EVENT,
    MXD_EMERGENCY_EVENT_TYPE_FOREIGN_AFFAIRS_SUDDEN_EVENT,
    MXD_EMERGENCY_EVENT_TYPE_WAR_SUDDEN_EVENT
}MXD_EMERGENCY_EVENT_TYPE;

typedef enum
{
    MXD_EMERGENCY_EVENT_LEVEL_STAY = 0,
    MXD_EMERGENCY_EVENT_LEVEL_SUPER,
    MXD_EMERGENCY_EVENT_LEVEL_VERY_IMPORTANT,
    MXD_EMERGENCY_EVENT_LEVEL_IMPORTANT,
    MXD_EMERGENCY_EVENT_LEVEL_GENERIC
}MXD_EMERGENCY_EVENT_LEVEL;

typedef struct _MXD_EMERGENCY_EVENT_INFO_T
{
    MXD_LANGUAGE_TYPE      eLanguage;
    MXD_UINT16             nTextLen;
    MXD_UINT8              *pText;
    MXD_UINT               nPromulgatorNameLen;
    MXD_UINT8              *pPromulgatorName;
    MXD_UINT16             nReferenceService;
    MXD_UINT8              nAuxIndex;
    struct _MXD_EMERGENCY_EVENT_INFO_T  *  next;
}MXD_EMERGENCY_EVENT_INFO;

typedef enum
{
    MXD_EMERGENCY_AUX_TYPE_STAY = 0,
    MXD_EMERGENCY_AUX_TYPE_AUDWAV,
    MXD_EMERGENCY_AUX_TYPE_SOUND,
    MXD_EMERGENCY_AUX_TYPE_PIC,
    MXD_EMERGENCY_AUX_TYPE_IMG
}MXD_EMERGENCY_AUX_TYPE;

typedef struct _MXD_EMERGENCY_AUX_DATA_T
{
    MXD_EMERGENCY_AUX_TYPE   eType;
    MXD_UINT16               nLen;
    MXD_UINT8                *pData;
    struct _MXD_EMERGENCY_AUX_DATA_T  *next;
}MXD_EMERGENCY_AUX_DATA;

typedef struct
{
    MXD_UINT16                   nId;
    MXD_EMERGENCY_EVENT_TYPE     eType;
    MXD_EMERGENCY_EVENT_LEVEL    eLevel;
    MXD_UINT8                    nCharset;
	MXD_DATE_TIME				 sSendDateTime;
    MXD_UINT32                   nDuration;
    MXD_UINT8                    nLanguageNum;
    MXD_EMERGENCY_EVENT_INFO     *pEventInfo;
    MXD_UINT8                    nAuxDataNum;
    MXD_EMERGENCY_AUX_DATA       *pAuxData;
}MXD_EMERGENCY_MSG;

typedef struct
{
    MXD_UINT16                nMsgId;
    MXD_EMERGENCY_EVENT_TYPE  eMsgType;
    MXD_EMERGENCY_EVENT_LEVEL eMsgLevel;
    MXD_UINT8                 nNetLevel;
    MXD_UINT16                nNetId;
    MXD_SYS_FREQPOINT         tFreqPoint;
}MXD_EMERGENCY_TRIGGER;

/////////*ESG structs*//////////////////////////////////////////

typedef enum
{
    MXD_MEDIA_USAGE_BACKGROUD=1,
    MXD_MEDIA_USAGE_LOGO=2,
    MXD_MEDIA_USAGE_POSTER=3,
    MXD_MEDIA_USAGE_PREVUE=4,
    MXD_MEDIA_USAGE_ADVERT=5
}MXD_MEDIA_USAGE;

typedef struct
{
    MXD_MEDIA_USAGE     Usage;
    MXD_INT8			*Type;
    MXD_INT8           *Data;
}MXD_MEDIA;

typedef enum
{
    MXD_SERVICE_CLASS_TV=1,
    MXD_SERVICE_CLASS_AUDIO_BROADCAST=2,
    MXD_SERVICE_CLASS_VIDEO_CLIP=3,
    MXD_SERVICE_CLASS_FILE_DOWNLOAD=4,
    MXD_SERVICE_CLASS_SOFT_MANAGE=5,
    MXD_SERVICE_CLASS_ESG=6,
    MXD_SERVICE_CLASS_STREAM_DATA=7
}MXD_SERVICE_CLASS;

typedef struct
{
	MXD_LANGUAGE_TYPE      Lang;
	MXD_INT8               *Name;
}MXD_SERVICE_NAME;

typedef struct
{
    MXD_UINT16          ServiceId;
    MXD_UINT16          Genre;
    MXD_SERVICE_CLASS   Class;
    MXD_UINT16          ParaId;
    MXD_BOOL            ForFree;
    MXD_UINT8           *CaDescriptor;
	MXD_UINT16			nServiceNameCount;
    MXD_SERVICE_NAME	*pServiceNameArray;
}MXD_SERVICE_INFO;

typedef struct
{
	MXD_LANGUAGE_TYPE   Lang;
	MXD_INT8           *Description;
	MXD_INT8           *Provider;
	MXD_INT8           *LangStr;
}MXD_SERVICE_AUX_TEXT;

typedef struct
{
    MXD_UINT16				ServiceId;
	MXD_UINT16				nAuxTextCount;
    MXD_SERVICE_AUX_TEXT	*pAuxTextArray;
	MXD_UINT16				nMediaCount;
    MXD_MEDIA				*pMediaArray;
    MXD_INT8				*ExtentInfo;
}MXD_SERVICE_AUX_INFO;

typedef struct
{
    MXD_LANGUAGE_TYPE      Lang;
    MXD_INT8                *Str;
}MXD_SCHEDULE_TITLE;

typedef struct
{
    MXD_INT8 *Date;
    MXD_INT8 *Time;
}MXD_DATE_TIME_STR;

typedef struct
{
    MXD_UINT16              ScheduleId;
    MXD_UINT16              ServiceId;
    MXD_UINT16              ContentId;
	MXD_UINT16				nTitleCount;
    MXD_SCHEDULE_TITLE      *pTitleArray;
    MXD_DATE_TIME_STR       StartTime;
    MXD_BOOL                ForFree;
    MXD_BOOL                Live;
    MXD_BOOL                Repeat;
    MXD_UINT8				*CaDescriptor;
}MXD_SCHEDULE_INFO;

typedef struct
{
    MXD_INT8                *Keyword;
    MXD_INT8                *DigestInfo;
    MXD_INT8                *Title;
    MXD_LANGUAGE_TYPE      AudioLang;
    MXD_LANGUAGE_TYPE      SubTitleLang;
    MXD_LANGUAGE_TYPE      Lang;
}MXD_CONTENT_TEXT;

typedef struct
{
    MXD_UINT16              ContentId;
    MXD_INT8				*ContentClass;
    MXD_UINT16              Genre;
    MXD_UINT16              Duration;
	MXD_UINT16				nMediaCount;
    MXD_MEDIA               *pMediaArray;
	MXD_UINT16				nTextCount;
    MXD_CONTENT_TEXT        *pTextArray;
    MXD_UINT16              ServiceParaId;
    MXD_INT8               *ExtentInfo;
}MXD_CONTENT_INFO;

typedef struct
{
    MXD_UINT8       VideoStreamIndex;
    MXD_UINT8       Codec;
    MXD_UINT16      Width;
    MXD_UINT16      Height;
    MXD_UINT8       FrameRate;
    MXD_INT8        *H264ParaSets;
}MXD_VIDEO_STREAM_PARA;

typedef struct
{
    MXD_UINT8       AudioStreamIndex;
    MXD_UINT8       Codec;
    MXD_UINT8       SampleRate;
    MXD_UINT8       Channel;
    MXD_BOOL        LATMCfgInPayload;
    MXD_INT8        *LATMConfig;
}MXD_AUDIO_STREAM_PARA;

typedef struct
{
    MXD_UINT8       Codec;
}MXD_DATA_STREAM_PARA;

typedef struct
{
    MXD_UINT16      SizeLength;
    MXD_UINT16      IndexLength;
    MXD_UINT16      IndexDeltaLength;
}MXD_ENCRYPT_PARA;

typedef struct
{
    MXD_UINT16              ParaId;
	MXD_UINT16				nVideoStreamParaCount;
    MXD_VIDEO_STREAM_PARA   *pVideoStreamParaArray;
	MXD_UINT16				nAudioStreamParaCount;
    MXD_AUDIO_STREAM_PARA   *pAudioStreamParaArray;
    MXD_DATA_STREAM_PARA    DataStreamPara;
    MXD_ENCRYPT_PARA        EncryptPara;
}MXD_SERVICE_PARA;

typedef struct
{
	MXD_UINT16				nSerInfoCount;
    MXD_SERVICE_INFO        *pSerInfoArray;
	MXD_UINT16				nAuxInfoCount;
    MXD_SERVICE_AUX_INFO    *pAuxInfoArray;
	MXD_UINT16				nSchInfoCount;
    MXD_SCHEDULE_INFO       *pSchInfoArray;
	MXD_UINT16				nContentInfoCount;
    MXD_CONTENT_INFO        *pContentInfoArray;
	MXD_UINT16				nParaInfoCount;
    MXD_SERVICE_PARA        *pParaInfoArray;
}MXD_ESG_DATA;

typedef struct
{
    MXD_DATE_TIME         StartTime;
    MXD_UINT16       DurationTime;
    MXD_LANGUAGE_TYPE          Language;
    MXD_UINT8        ThemeLength;
    MXD_INT8         *ThemeContent;
}MXD_PROMPT_INFO;

////////*CA Info structs*///////////////////////////////////////////
typedef struct
{
	MXD_UINT16     nCaId;
	MXD_UINT16      nServiceId;
	MXD_UINT8       nEmmDataType;
	MXD_UINT8       nEcmDataType;
}MXD_EADT_INFO;

typedef struct
{
	MXD_UINT16     ResourceID;
	MXD_UINT16     BlockNo;
	MXD_UINT16     SliceNo;
	MXD_UINT8       ReflashNo;
	MXD_UINT32     DataLen;
	MXD_UINT8*	   pData;
}MXD_FILE_BLOCK;

typedef struct
{
	MXD_UINT16     ResourceID;
	MXD_UINT8       SliceNo;
	MXD_UINT8       ReflashNo;
	MXD_UINT8       ZipType;
	MXD_UINT8       LastSliceNo;
	MXD_UINT32     DataLen;
	MXD_UINT8*	   pData;
}MXD_FILEFAT_SLICE;

////////*Service Info structs*///////////////////////////////////////////
typedef enum
{
    MXD_CMMBSERVICE_TYPE_TV=0,
    MXD_CMMBSERVICE_TYPE_ESG,
    MXD_CMMBSERVICE_TYPE_EMM,
    MXD_CMMBSERVICE_TYPE_STREAM_DATA,
    MXD_CMMBSERVICE_TYPE_AUDIO,
    MXD_CMMBSERVICE_TYPE_FILE_DATA,
    MXD_CMMBSERVICE_TYPE_MANAGE,
    MXD_CMMBSERVICE_TYPE_SHORT_VIDEO,
    MXD_CMMBSERVICE_UNKNOWN,
    MXD_CMMBSERVICE_EMPTY,
}MXD_CMMBSERVICE_TYPE;

typedef enum{
	MXD_MODULATE_TYPE_BPSK = 0,	
	MXD_MODULATE_TYPE_QPSK = 1,	
	MXD_MODULATE_TYPE_16QAM = 2,
}MXD_MODULATE_TYPE;

typedef enum{
	MXD_RS_MODE_240_240 = 0, 	// RS(240,240)
	MXD_RS_MODE_240_224 = 1, 	// RS(240,224)
	MXD_RS_MODE_240_192 = 2, 	// RS(240,192)
	MXD_RS_MODE_240_176 = 3	 	// RS(240,176)
}MXD_RS_MODE;


typedef enum{
	MXD_INTERLEAVE_MODE_RERSERVE= 0, 
	MXD_INTERLEAVE_MODE_MODE_1 = 1,	
	MXD_INTERLEAVE_MODE_MODE_2 = 2,	
	MXD_INTERLEAVE_MODE_MODE_3 = 3
}MXD_INTERLEAVE_MODE;

typedef enum{
	MXD_LDPC_MODE_1_DIV_2 = 0,
	MXD_LDPC_MODE_3_DIV_4 = 1,
}MXD_LDPC_MODE;

#define MXD_CMMBSERVICE_NAME_MAX 40

typedef struct
{
	MXD_UINT32            nServiceID;
	MXD_CMMBSERVICE_TYPE  eServiceType; 	    //Service Type
	MXD_UINT8 			  nServiceNameLen;	   //
	MXD_UINT8 			  szServiceName[MXD_CMMBSERVICE_NAME_MAX];	// 2-40Bytes channel name, e.g. CCTV-1
	MXD_MODULATE_TYPE     eModuType;
	MXD_RS_MODE           eRsMode;
	MXD_INTERLEAVE_MODE   eInterleaveMode;
	MXD_LDPC_MODE         eLdpcMode;
	MXD_UINT8 			  nDisturbMode;
	MXD_UINT8             nStartTs;			   // the start timeslot
	MXD_UINT8             nTsCount;				   // the count of timeslot
	MXD_UINT8             nSubFrameID;			// the subframe id
	MXD_UINT8             nMF_ID;				   // Frame id
	MXD_BOOL              bFree;				   // free service?
}MXD_CMMBSERVICE_INFO;


/************************* Callback Function Definition ****************************/

/*!
 * \par Description
 * This function OnServiceChannelList is a callback function! host need implement it and sdk will call it after service channel inforamtion is parsed. 
 * Notice: since the data given by this function is not demuxed, so it is useful when host want record the whole cmmb frame to disk.
 *
 * \param nDemodChipIndex	[IN] the chip index which host is operating, the first index is 0;
 * \param userParam	[IN] the parameter give by MXD_StartService;
 * \param nCurrentFreqKhz	[IN] the frequency to search, in KHz;
 * \param service_count	[IN] the service channel count in this frequency; it is 0 when no service found.
 * \param pinfo	[IN] the service channel detail in this frequency;
 *
 * \return   
 *    MXD_SERVICESEARCH_STOP - tell sdk to stop further service search job.
 *    MXD_RTN_OK	-	sdk continue further service search job.
 *
 * \warning    
 */
typedef MXD_RETURN_CODE MXD_EXPORT ( *CB_OnServiceSearchResult)( MXD_UINT8 nDemodChipIndex, void* userParam, MXD_UINT32 nCurrentFreqKhz, MXD_CMMBSERVICE_INFO *pinfo, MXD_UINT32 service_count );

/*!
 * \par Description
 * This function OnRawFrame is a callback function! host need implement it and sdk will call in it after cmmb frame received. 
 * Notice: since the data given by this function is not demuxed, so it is useful when host want record the whole cmmb frame to disk.
 *
 * \param nDemodChipIndex	[IN] the chip index which host is operating, the first index is 0;
 * \param serviceID	[IN] service id;
 * \param userParam	[IN] the parameter give by MXD_StartService;
 * \param frameData	[IN] the raw frame data, not demuxed!;
 * \param dataSize	[IN] the raw frame data size;
 *
 * \return   
 *    MXD_DEMUXER_STOP	-	host will do demux by himself, sdk will give up further demux job.
 *    Others	-	sdk will continue the demux job.
 *
 * \warning    
 */
typedef MXD_RETURN_CODE MXD_EXPORT ( *CB_OnRawFrame)( MXD_UINT8 nDemodChipIndex, MXD_UINT32 serviceID, void* userParam, MXD_UINT8* frameData, MXD_UINT32 dataSize  );

/*!
 * \par Description
 * This function OnRawSubFrameForDescrambling is a callback function! if host don't want to do Descrambling, please do not implement this function. 
 * Notice: this function is used to pass un-descrambed sub-frame into the CAS system and get Descrambled sub-frame from CAS strem. 
 *
 * \param nDemodChipIndex	[IN] the chip index which host is operating, the first index is 0;
 * \param serviceID	[IN] service id;
 * \param userParam	[IN] the parameter give by MXD_StartService;
 * \param frameOrgData	[IN] the raw frame data;
 * \param dataOrgSize	[IN] the raw frame data size;
 * \param frameDescrambledData	[OUT] the Descrambled frame data buffer to fill;
 * \param pdataDescrambledSize	[OUT] before Descrambling, this valuable is the data buffer size to fill; after Descrambling, this valuable is the actual Descrambled subframe data length;
 *
 * \return   
 *    MXD_DEMUXER_STOP	-	host will do demux by himself, sdk will give up further demux job.
 *    MXD_DESCRAMBLE_OK - subframe descramble ok, demuxer will use new buffer to do further job.
 *    MXD_RTN_OK	-	sdk will continue the demux job.
 *
 * \warning    
 */
typedef MXD_RETURN_CODE MXD_EXPORT ( *CB_OnRawFrameForDescrambling)( MXD_UINT8 nDemodChipIndex, MXD_UINT32 serviceID, void* userParam, MXD_UINT8* frameOrgData, MXD_UINT32 dataOrgSize, MXD_MEDIA_UNIT_IN_FRAME sMediaUnits, MXD_BOOL bHasEcmInFrame, MXD_UINT8* frameDescrambledData, MXD_UINT32* pdataDescrambledSize );

/*!
 * \par Description
 * This function OnRawSubFrameForDescrambling is a callback function! if host don't want to do Descrambling, please do not implement this function. 
 * Notice: this function is used to pass un-descrambed sub-frame into the CAS system and get Descrambled sub-frame from CAS strem. 
 *
 * \param nDemodChipIndex	[IN] the chip index which host is operating, the first index is 0;
 * \param serviceID	[IN] service id;
 * \param userParam	[IN] the parameter give by MXD_StartService;
 * \param bIsEmmSubframe	[IN] is this subframe emm?;
 * \param subframeOrgData	[IN] the raw subframe data;
 * \param dataOrgSize	[IN] the raw frame data size;
 * \param subframeDescrambledData	[OUT] the Descrambled subframe data buffer to fill;
 * \param pdataDescrambledSize	[OUT] before Descrambling, this valuable is the data buffer size to fill; after Descrambling, this valuable is the actual Descrambled subframe data length;
 *
 * \return   
 *    MXD_DEMUXER_STOP	-	host will do demux by himself, sdk will give up further demux job.
 *    MXD_DESCRAMBLE_OK - subframe descramble ok, demuxer will use new buffer to do further job.
 *    MXD_RTN_OK	-	sdk will continue the demux job.
 *
 * \warning    
 */
typedef MXD_RETURN_CODE MXD_EXPORT ( *CB_OnRawSubFrameForDescrambling)( MXD_UINT8 nDemodChipIndex, MXD_UINT32 serviceID, void* userParam, MXD_UINT8* subframeOrgData, MXD_UINT32 dataOrgSize, MXD_UINT8* subframeDescrambledData, MXD_UINT32* pdataDescrambledSize );

/*!
 * \par Description
 * This function OnEmergencyMsg is a callback function! host need implement it and sdk will call in it after finished cmmb frame demuxing. 
 * When emergency message arrived, sdk will call this callback.
 *
 * \param nDemodChipIndex	[IN] the chip index which host is operating, the first index is 0;
 * \param pMsg	[IN] the message data in struct, it will be NULL if current frequency just have trigger!;
 * \param pTrigger	[IN] the trigger message data in struct, it will be NULL if current frequency have the message body!;
 *
 * \return   
 *    MXD_RTN_OK	-	host has dealed with the message correctly.
 *    Others	-	reseved for further use.
 *
 * \warning    
 */
typedef MXD_RETURN_CODE MXD_EXPORT ( *CB_OnEmergencyMsg)( MXD_UINT8 nDemodChipIndex, MXD_EMERGENCY_MSG* pMsg, MXD_EMERGENCY_TRIGGER *pTrigger );

/*!
 * \par Description
 * This function OnVideoUnit is a callback function! host need implement it and sdk will call in it after finished cmmb frame demuxing. 
 * In this function, host could send the demuxed video data to decoder.
 *
 * \param nDemodChipIndex	[IN] the chip index which host is operating, the first index is 0;
 * \param serviceID	[IN] service id;
 * \param userParam	[IN] the parameter give by MXD_StartService;
 * \param tParam	[IN] the video param data struct for current frame;
 * \param videoFrames	[IN] the video frames in chain list;
 *
 * \return   
 *    MXD_RTN_OK	-	host has dealed with the video data correctly.
 *    Others	-	reseved for further use.
 *
 * \warning    
 */
typedef MXD_RETURN_CODE MXD_EXPORT ( *CB_OnVideoUnit)( MXD_UINT8 nDemodChipIndex, MXD_UINT32 serviceID, void* userParam, MXD_VIDEO_PARAM *tParam, MXD_STREAM_VIDEO_FRAME* videoFrames );

/*!
 * \par Description
 * This function OnAudioUnit is a callback function! host need implement it and sdk will call in it after finished cmmb frame demuxing. 
 * In this function, host could send the demuxed audio data to decoder.
 *
 * \param nDemodChipIndex	[IN] the chip index which host is operating, the first index is 0;
 * \param serviceID	[IN] service id;
 * \param userParam	[IN] the parameter give by MXD_StartService;
 * \param tParam	[IN] the audio param data struct for current frame;
 * \param audioFrames	[IN] the audio frames in chain list;
 *
 * \return   
 *    MXD_RTN_OK	-	host has dealed with the audio data correctly.
 *    Others	-	reseved for further use.
 *
 * \warning    
 */
typedef MXD_RETURN_CODE MXD_EXPORT ( *CB_OnAudioUnit)( MXD_UINT8 nDemodChipIndex, MXD_UINT32 serviceID, void* userParam, MXD_AUDIO_PARAM *tParam, MXD_STREAM_AUDIO_FRAME* audioFrames );

/*!
 * \par Description
 * This function OnEsgData is a callback function! host need implement it and sdk will call in it after finished cmmb frame demuxing. 
 * In this function, host could send the demuxed esg data to UI.
 *
 * \param nDemodChipIndex	[IN] the chip index which host is operating, the first index is 0;
 * \param serviceID	[IN] service id;
 * \param userParam	[IN] the parameter give by MXD_StartService;
 * \param pEsgdata	[IN] the esg data struct;
 *
 * \return   
 *    MXD_RTN_OK	-	host has dealed with the data correctly.
 *    Others	-	reseved for further use.
 *
 * \warning    
 */
typedef MXD_RETURN_CODE MXD_EXPORT ( *CB_OnEsgData)( MXD_UINT8 nDemodChipIndex, MXD_UINT32 serviceID, void* userParam, MXD_ESG_DATA *pEsgdata );

/*!
 * \par Description
 * This function OnProgramPrompt is a callback function! host need implement it and sdk will call in it after finished cmmb frame demuxing. 
 * Program prompt is a type of ESG data, but it send within the service frame.
 * In this function, host could send the demuxed program prompt data to UI.
 *
 * \param nDemodChipIndex	[IN] the chip index which host is operating, the first index is 0;
 * \param serviceID	[IN] service id;
 * \param userParam	[IN] the parameter give by MXD_StartService;
 * \param pProgramPrompt	[IN] the esg program prompt data struct;
 *
 * \return   
 *    MXD_RTN_OK	-	host has dealed with the data correctly.
 *    Others	-	reseved for further use.
 *
 * \warning    
 */
typedef MXD_RETURN_CODE MXD_EXPORT ( *CB_OnProgramPrompt)( MXD_UINT8 nDemodChipIndex, MXD_UINT32 serviceID, void* userParam, MXD_PROMPT_INFO *pProgramPrompt, MXD_UINT8 nPromptRecCount );

/*!
 * \par Description
 * This function OnEadtInfo is a callback function! host need implement it and sdk will call it after service channel inforamtion is parsed. 
 * Demuxer will call this after it got EADT Table from CLCH.
 *
 * \param nDemodChipIndex	[IN] the chip index which host is operating, the first index is 0;
 * \param userParam	[IN] the parameter give by MXD_StartService;
 * \param peadtinfo	[IN] the CA EADT information from CLCH;
 * \param eadt_count	[IN] the count of EADT.
 *
 * \return   
 *    MXD_RTN_OK	-	.
 *
 * \warning    
 */
typedef MXD_RETURN_CODE MXD_EXPORT ( *CB_OnEadtInfo)( MXD_UINT8 nDemodChipIndex, void* userParam, MXD_EADT_INFO *peadtinfo, MXD_UINT32 eadt_count, MXD_UINT8* pRawCaTab, MXD_UINT32 nCaTabLen );

/*!
 * \par Description
 * This function OnEadtInfo is a callback function! host need implement it and sdk will call it after service channel inforamtion is parsed. 
 * Demuxer will call this function after it got Ecm information from Service stream.
 *
 * \param nDemodChipIndex	[IN] the chip index which host is operating, the first index is 0;
 * \param userParam	[IN] the parameter give by MXD_StartService;
 * \param nEcmDataType	[IN] the Ecm data type;
 * \param ecmData	[IN] the Ecm data;
 * \param dataSize	[IN] the Ecm data size;
 *
 * \return   
 *    MXD_RTN_OK	-	.
 *
 * \warning    
 */
typedef MXD_RETURN_CODE MXD_EXPORT ( *CB_OnEcmPacket)( MXD_UINT8 nDemodChipIndex, MXD_UINT32 serviceID, void* userParam, MXD_UINT8 nEcmDataType , MXD_UINT8* ecmData, MXD_UINT32 dataSize );

/*!
 * \par Description
 * This function OnEadtInfo is a callback function! host need implement it and sdk will call it after service channel inforamtion is parsed. 
 * Demuxer will call this function after it got Emm stream.
 *
 * \param nDemodChipIndex	[IN] the chip index which host is operating, the first index is 0;
 * \param userParam	[IN] the parameter give by MXD_StartService;
 * \param nEmmDataType	[IN] the Emm data type;
 * \param emmData	[IN] the Emm data;
 * \param dataSize	[IN] the Emm data size;
 *
 * \return   
 *    MXD_RTN_OK	-	.
 *
 * \warning    
 */
typedef MXD_RETURN_CODE MXD_EXPORT ( *CB_OnEmmPacket)( MXD_UINT8 nDemodChipIndex, MXD_UINT32 serviceID, void* userParam, MXD_UINT8 nEmmDataType, MXD_UINT8* emmData, MXD_UINT32 dataSize );

typedef MXD_RETURN_CODE MXD_EXPORT ( *CB_OnFileXpeData)( MXD_UINT8 nDemodChipIndex, MXD_UINT32 serviceID, void* userParam, MXD_BOOL bIsFatData, MXD_UINT8 TransmitNo, MXD_FILE_BLOCK* pFileBlock, MXD_FILEFAT_SLICE* pFatSlice, MXD_UINT32 nCount );

typedef MXD_RETURN_CODE MXD_EXPORT ( *CB_OnStreamXpeData)( MXD_UINT8 nDemodChipIndex, MXD_UINT32 serviceID, void* userParam, MXD_UINT8 TransmitNo, MXD_UINT8* pData, MXD_UINT32 dataSize );

/*!
 * \par Description
 * This function OnReadTsData is a callback function! host need implement it and sdk will call when it need read ts data. 
 *
 * \param nDemodChipIndex	[IN] the chip index which host is operating, the first index is 0;
 * \param ppTsData	[OUT] the raw ts stream data;
 * \param pDataSize	[OUT] the ts data size;
 *
 * \return   
 *    MXD_DEMUXER_OK	-	host read data correctly.
 *    Others	-	sdk will skip further work.
 *
 * \warning    
 */
typedef MXD_RETURN_CODE MXD_EXPORT ( *CB_OnReadTsData)( MXD_UINT8 nDemodChipIndex, MXD_UINT8** ppTsData, MXD_UINT32* pDataSize  );

typedef MXD_RETURN_CODE MXD_EXPORT ( *CB_OnCallExtXmlParser)( MXD_UINT8 nDemodChipIndex, MXD_UINT32 serviceID, void* userParam, MXD_UINT8 nEsgType, MXD_INT8* pXmlBuf, MXD_INT32 nXmlBufLen );

/**
 * MXD_CALLBACKs definition
 */
typedef struct __MXD_CALLBACKs__
{
	CB_OnServiceSearchResult			OnServiceSearchResult;
	CB_OnVideoUnit						OnVideoUnit;
	CB_OnAudioUnit						OnAudioUnit;
	CB_OnEsgData						OnEsgData;
	CB_OnEmergencyMsg					OnEmergencyMsg;
	CB_OnProgramPrompt					OnProgramPrompt;
	CB_OnRawFrame						OnRawFrame;						
	CB_OnRawFrameForDescrambling		OnRawFrameForDescrambling;						
	CB_OnRawSubFrameForDescrambling     OnRawSubFrameForDescrambling;	
	CB_OnReadTsData						OnReadTsData;
	CB_OnEadtInfo						OnEadtInfo;
	CB_OnEcmPacket						OnEcmPacket;
	CB_OnEmmPacket						OnEmmPacket;
	CB_OnCallExtXmlParser				OnCallExtXmlParser;
	CB_OnFileXpeData					OnFileXpeData;
	CB_OnStreamXpeData					OnStreamXpeData;
} MXD_CALLBACKs;

/************************* Function Definition ****************************/

/*!
 * \par Description
 * This function is used to initialize sdk.
 * Notice: this SDK could support more than one demod chip operation at once. a handle will br created by this function and other function must have this handle to do further operation .
 *
 * \param nDemodChipIndex	[IN] the chip index which host is operating, the first index is 0;
 * \param callbacks	[IN] give callback functions;
 *
 * \return   
 *    HANDLE of new device	- this handle need pass in to other functions.
 *    NULL	-	the Device create failed.
 *
 * \warning    
 */
MXD_HANDLE MXD_EXPORT MXD_OpenDevice( MXD_UINT8 nDemodChipIndex, MXD_CALLBACKs* callbacks );

/*!
 * \par Description
 * This function is used to close device.
 *
 * \param hDevice	[IN] the handle of chip device which host is operating;
 *
 * \return   
 *    MXD_RTN_OK	-	the call succeeded
 *
 * \warning    
 */
MXD_RETURN_CODE MXD_EXPORT MXD_CloseDevice( MXD_HANDLE hDevice );

/*!
 * \par Description
 * This function is used to start a service channel search progress. this function will return immeditely and the service channel information will come back to the callback functions.
 *
 * \param hDevice	[IN] the handle of chip device which host is operating;
 * \param userParam	[IN]	this parameter will give back to host when SDK call in the callback functions.
 * \param nBeginFreqKhz	[IN] the begin freqency to tune, unit is khz
 * \param nEndFreqKhz	[IN] the end freqency to tune, unit is khz
 * \param nStepFreqKhz	[IN] the step of two freqency to tune, unit is khz
 * \param bGetServiceName	[IN] if this parameter is 1, then sdk will try to get service name from the ESG.
 *
 * \return   
 *    MXD_RTN_OK	-	the call succeeded
 *
 * \warning      
 */
MXD_RETURN_CODE MXD_EXPORT MXD_StartServiceSearch( MXD_HANDLE hDevice, void* userParam, MXD_UINT32 nBeginFreqKhz, MXD_UINT32 nEndFreqKhz, MXD_UINT32 nStepFreqKhz, MXD_BOOL bGetServiceName );

/*!
 * \par Description
 * This function is used to stop current service search progress.
 *
 * \param hDevice	[IN] the handle of chip device which host is operating;
 *
 * \return   
 *    MXD_RTN_OK	-	the call succeeded
 *
 * \warning    
 */
MXD_RETURN_CODE MXD_EXPORT MXD_StopServiceSearch( MXD_HANDLE hDevice );

/*!
 * \par Description
 * This function is used to lock signal at given freq. this function will return after signal is locked or timeout.
 *
 * \param hDevice	[IN] the handle of chip device which host is operating;
 * \param nFreqKhz	[IN] the freqency to tune, unit is khz
 * \param nTimeOut	[IN] the preset time for try to lock the siganl, unit is ms
 *
 * \return   
 *    MXD_RTN_OK	-	the call succeeded
 *
 * \warning      
 */
MXD_RETURN_CODE MXD_EXPORT MXD_LockFrequency( MXD_HANDLE hDevice, MXD_UINT32 nFreqKhz, MXD_UINT32 nTimeOut );

/*!
 * \par Description
 * This function is used to search service channel list from locked freq. this function will return until the service channel information come back or timeout accou.
 *
 * \param hDevice	[IN] the handle of chip device which host is operating;
 * \param pinfo	[OUT] the service channel detail in locked frequency;
 * \param service_count	[OUT] the service channel count in locked frequency;
 * \param nTimeOut	[IN] the preset time for try to lock the siganl, unit is ms
 *
 * \return   
 *    MXD_RTN_OK	-	the call succeeded
 *
 * \warning      
 */
MXD_RETURN_CODE MXD_EXPORT MXD_RecieveServiceList( MXD_HANDLE hDevice, MXD_CMMBSERVICE_INFO **ppinfo, MXD_UINT32 *pservice_count, MXD_UINT32 nTimeOut, MXD_BOOL bGetServiceName );

/*!
 * \par Description
 * This function is used to set tuner frequency after lock the signal.
 *
 * \param pSavedSeviceChannelList	[ IN ]	saved service channel list.
 * \param service_count	[ IN ]	service count in the service channel list.
 *
 * \return   
 *    MXD_RTN_OK	-	the call succeeded
 *
 * \warning      
 */
MXD_RETURN_CODE MXD_EXPORT MXD_RestoreServiceList( MXD_HANDLE hDevice, MXD_CMMBSERVICE_INFO *pSavedSeviceChannelList, MXD_UINT32 service_count );

/*!
 * \par Description
 * This function is used to start a service channel. the service data will come back to the callback functions.
 *
 * \param hDevice	[IN] the handle of chip device which host is operating;
 * \param serviceID	[IN]	the ID of the channel service.
 * \param userParam	[IN]	this parameter will give back to host when SDK call in the callback functions.
 *
 * \return   
 *    MXD_RTN_OK	-	the call succeeded
 *
 * \warning      
 */
MXD_RETURN_CODE MXD_EXPORT MXD_PlayService( MXD_HANDLE hDevice, MXD_UINT32 serviceID, void* userParam );

/*!
 * \par Description
 * This function is used to stop a service channel.
 *
 * \param hDevice	[IN] the handle of chip device which host is operating;
 * \param serviceID	[IN]	the ID of the channel service.
 *
 * \return   
 *    MXD_RTN_OK	-	the call succeeded
 *
 * \warning    
 */
MXD_RETURN_CODE MXD_EXPORT MXD_StopService( MXD_HANDLE hDevice, MXD_UINT32 serviceID );

/*!
 * \par Description
 * This function intercept all started service. When service data arrived, it will demux received data and call registed callback functions. Without it all callback functions will not work!
 * This function must been called from an High ISR routine or a Timer task. 
 * If host call this function in a timer task, the period of two calling must no longer than 100ms.
 *
 * \param hDevice	[IN] the handle of chip device which host is operating;
 *
 * \return   
 *    MXD_RTN_OK	-	the call succeeded
 *
 * \warning     
 */
MXD_RETURN_CODE MXD_EXPORT MXD_PulseProcess( MXD_HANDLE hDevice );

/*!
 * \par Description
 * Get MIRA System Status.
 *
 * \param hDevice	[IN] the handle of chip device which host is operating;
 * \param sys_status	[OUT]	the system status.
 *
 * \return   
 *    MXD_RTN_OK	-	the call succeeded
 *
 * \warning     
 */
MXD_RETURN_CODE MXD_EXPORT MXD_GetSystemStatus( MXD_HANDLE hDevice, MXD_SYS_STATUS *sys_status );

/*!
 * \par Description
 * This function only used when Mpeg2TS interface is enabled. It will demux received Mpeg2TS packet data and call registed callback functions .
 * Notice: host must pass in received data from the TS interface without any process!
 *
 * \param hDevice	[IN] the handle of chip device which host is operating;
 * \param tsData	[IN] the mpeg2 ts data;
 * \param dataSize	[IN] the data size;
 *
 * \return   
 *    MXD_RTN_OK	-	the call succeeded
 *
 * \warning     
 */
MXD_RETURN_CODE MXD_EXPORT MXD_TSPacketProcess( MXD_HANDLE hDevice, MXD_UINT8* tsData, MXD_UINT32 dataSize );

/*!
 * \par Description
 * This function is used to start a esg service channel. this function will return immeditely and specified type's ESG data will come back to the callback functions.
 *
 * \param hDevice	[IN] the handle of chip device which host is operating;
 * \param userParam	[IN]	this parameter will give back to host when SDK call in the callback functions.
 * \param nEsgDataTypeId	[IN] the type id of esg data, 0 means all types data.
 *
 * \return   
 *    MXD_RTN_OK	-	the call succeeded
 *
 * \warning      
 */
MXD_RETURN_CODE MXD_EXPORT MXD_StartEsgRecieving( MXD_HANDLE hDevice, void* userParam, MXD_UINT8 nEsgDataTypeId );

/*!
 * \par Description
 * This function is used to stop esg service.
 *
 * \param hDevice	[IN] the handle of chip device which host is operating;
 *
 * \return   
 *    MXD_RTN_OK	-	the call succeeded
 *
 * \warning    
 */
MXD_RETURN_CODE MXD_EXPORT MXD_StopEsgRecieving( MXD_HANDLE hDevice );

/*!
 * \par Description
 * Read tuner register value.
 * Set Power Management.
 *
 * \param hDevice	[IN] the handle of chip device which host is operating;
 * \param pm	[IN]	mode of power management, MXD_PM_SUSPEND or MXD_PM_RESUME.
 *
 * \return   
 *    MXD_RTN_OK	-	the call succeeded
 *
 * \warning     
 */
MXD_RETURN_CODE MXD_EXPORT MXD_SetPowerManagement( MXD_HANDLE hDevice, MXD_PM_MODE pm );

/*!
 * \par Description
 * Write register value.
 *
 * \param hDevice	[IN] the handle of chip device which host is operating;
 * \param regAddr	[IN]	the address of register.
 * \param regValue	[IN]	the value of this register.
 *
 * \warning     
 */
MXD_RETURN_CODE MXD_EXPORT MXD_EX_WriteReg( MXD_HANDLE hDevice, MXD_UINT8 regAddr, MXD_UINT8 regValue);

/*!
 * \par Description
 * Read register value.
 *
 * \param hDevice	[IN] the handle of chip device which host is operating;
 * \param regAddr	[IN]	the address of register.
 * \param regValue	[OUT]	the value of this register.
 *
 * \return   
 *    MXD_RTN_OK	-	the call succeeded
 *
 * \warning     
 */
MXD_RETURN_CODE MXD_EXPORT MXD_EX_ReadReg( MXD_HANDLE hDevice, MXD_UINT8 regAddr, MXD_UINT8* regValue );

/*!
 * \par Description
 * Read tuner register value.
 *
 * \param hDevice	[IN] the handle of chip device which host is operating;
 * \param regAddr	[IN]	the address of tuner register.
 * \param regValue	[OUT]	the value of this tuner register.
 *
 * \return   
 *    MXD_RTN_OK	-	the call succeeded
 *
 * \return   
 *    MXD_RTN_OK	-	the call succeeded
 *
 * \warning     
 */
MXD_RETURN_CODE MXD_EXPORT MXD_EX_ReadTunerReg( MXD_HANDLE hDevice, MXD_UINT8 regAddr, MXD_UINT8* regValue );

/*!
 * \par Description
 * Write tuner register value.
 *
 * \param hDevice	[IN] the handle of chip device which host is operating;
 * \param regAddr	[IN]	the address of tuner register.
 * \param regValue	[IN]	the value of want to write.
 *
 * \return   
 *    MXD_RTN_OK	-	the call succeeded
 *
 * \warning     
 */
MXD_RETURN_CODE MXD_EXPORT MXD_EX_WriteTunerReg( MXD_HANDLE hDevice, MXD_UINT8 regAddr, MXD_UINT8 regValue );

/*!
 * \par Description
 * This function is used to Open CLCH service channel. the service data will come back to the callback functions.
 *
 * \param hDevice	[IN] the handle of chip device which host is operating;
 * \param userParam	[IN]	this parameter will give back to host when SDK call in the callback functions.
 *
 * \return   
 *    MXD_RTN_OK	-	the call succeeded
 *
 * \warning      
 */
MXD_RETURN_CODE MXD_EXPORT MXD_OpenCLCHService( MXD_HANDLE hDevice, void* userParam );
    
/*!
 * \par Description
 * This function is used to Close CLCH service channel.
 *
 * \param hDevice	[IN] the handle of chip device which host is operating;
 *
 * \return   
 *    MXD_RTN_OK	-	the call succeeded
 *
 * \warning      
 */
MXD_RETURN_CODE MXD_EXPORT MXD_StopCLCHService(MXD_HANDLE hDevice);

typedef struct
{
    MXD_UINT16      FreqPointId;
    MXD_UINT16      BandWidth;
    MXD_UINT32      CentralFreq;
}MXD_SYS_FREQPOINT_T;

typedef struct
{
    MXD_UINT8       NetLevel;
    MXD_UINT16      NetId;
    MXD_SYS_FREQPOINT_T    FreqPoint;
}MXD_SYS_NEAR_NET_T;

typedef struct
{
    MXD_UINT8                UpdateId;
    MXD_DATE_TIME            SysTime;
    MXD_UINT8                CountryCode[3];
    MXD_UINT8                NetMode;
    MXD_UINT8                NetLevel;
    MXD_UINT16               NetId;
    MXD_UINT8                NetNameLength;
    MXD_UINT8                NetName[255+1];
    MXD_UINT16               FreqPointId;
    MXD_UINT32               CentralFreq;
    MXD_UINT16               BandWidth;
    MXD_UINT16               OtherFreqPointNum;
    MXD_SYS_FREQPOINT_T		 OtherFreqPoint[15];
    MXD_UINT8                NearNetNum;
    MXD_SYS_NEAR_NET_T       NearNet[15];
}MXD_SYS_NIT_CONF_T;

/*!
 * \par Description
 * This function is used get the extended information from Clch which have not retrun from the GetSeviceInfo function.
 *
 * \param hDevice	[IN] the handle of chip device which host is operating;
 * \param pNIT_Info	[OUT] return the information from NIT Table.
 *
 * \return   
 *    MXD_RTN_OK	-	the call succeeded
 *
 * \warning      
 */
MXD_RETURN_CODE MXD_EXPORT MXD_GetExtendedClchInfo( MXD_HANDLE hDevice, MXD_SYS_NIT_CONF_T* pNIT_Info );

#ifdef __cplusplus
}
#endif

#endif /* __MXD_SDK_API_H__ */

/* end of Mxd0250API.h */
